/* 
function isValidEmail(str){
  return /\w+@(\w+\.)+[a-z]{2,}/.test(str)
}

console.log(isValidEmail('zhang@qq.com'));
console.log(isValidEmail('zhang@qq.com.cn'));
console.log(isValidEmail('zhangqq.com.cn')); */

//把字符串单词的首字母换成大写

let str = 'good Good studY, Day a up';
// Good Good Study,Day Day Up

/* let result = str.replace(/\b\w+\b/g,function(matched){
    return matched.charAt(0).toUpperCase()+matched.slice(1).toLowerCase();
}); */
let result = str.replace(/\b(\w)(\w*)\b/g,function(matched,group1,group2){
    return group1.toUpperCase()+group2.toLowerCase();
});
console.log(result);

